

<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Blog - React</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta property="og:title" content="Blog - React">
  <meta property="og:type" content="website">
  <meta property="og:url" content="https://facebook.github.io/react/blog/page4/">
  <meta property="og:image" content="https://facebook.github.io/react/img/logo_og.png">
  <meta property="og:description" content="A JavaScript library for building user interfaces">
  <meta property="fb:app_id" content="623268441017527">

  <link rel="shortcut icon" href="/react/favicon.ico">
  <link rel="alternate" type="application/rss+xml" title="React" href="https://facebook.github.io/react/feed.xml">

  <link rel="stylesheet" href="//cdn.bootcss.com/docsearch.js/1.3.0/docsearch.min.css" />
  <link rel="stylesheet" href="/react/css/syntax.css">
  <link rel="stylesheet" href="/react/css/codemirror.css">
  <link rel="stylesheet" href="/react/css/react.css">

  <script src="//use.typekit.net/vqa1hcx.js"></script>
  <script>try{Typekit.load();}catch(e){}</script>

  <!--[if lte IE 8]>
  <script src="https://unpkg.com/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://unpkg.com/es5-shim@4.5.9/es5-shim.min.js"></script>
  <script src="https://unpkg.com/es5-shim@4.5.9/es5-sham.min.js"></script>
  <![endif]-->

  <script src="//cdn.bootcss.com/docsearch.js/1.5.0/docsearch.min.js"></script>
  <script src="//cdn.bootcss.com/codemirror/5.15.2/codemirror.js"></script>
  <script src="//cdn.bootcss.com/codemirror/5.15.2/mode/javascript/javascript.js"></script>
  <script src="//cdn.bootcss.com/codemirror/5.15.2/mode/xml/xml.js"></script>
  <script src="//cdn.bootcss.com/codemirror/5.15.2/mode/jsx/jsx.js"></script>
  <script src="//cdn.bootcss.com/react/15.5.4/react.min.js"></script>
  <script src="//cdn.bootcss.com/react/15.5.4/react-dom.min.js"></script>
  <script src="//cdn.bootcss.com/babel-standalone/6.15.0/babel.min.js"></script>

  <script src="/react/js/live_editor.js"></script>
</head>
<body>

  <div class="container">

    <div class="nav-main">
  <div class="wrap">
    <a class="nav-home" href="/react/">
      <img class="nav-logo" src="/react/img/logo.svg" width="36" height="36">
      React
    </a>
    <div class="nav-lists">
      <ul class="nav-site nav-site-internal">
        <li><a href="/react/docs/hello-world.html">Docs</a></li>
        <li><a href="/react/tutorial/tutorial.html">Tutorial</a></li>
        <li><a href="/react/community/support.html">Community</a></li>
        <li><a href="/react/blog/" class="active">Blog</a></li>
        <li class="nav-site-search">
          <input id="algolia-doc-search" type="text" placeholder="Search docs..." />
        </li>
      </ul>
      <ul class="nav-site nav-site-external">
        <li><a href="https://github.com/facebook/react">GitHub</a></li>
        <li><a href="https://github.com/facebook/react/releases">v15.5.4</a></li>
      </ul>
    </div>
  </div>
</div>


    <section class="content wrap blogContent">
  <div class="nav-docs nav-blog">
  <div class="nav-docs-section">
    <h3>Recent posts</h3>
    <ul>
      
        <li><a href="/react/blog/2017/04/07/react-v15.5.0.html">React v15.5.0</a></li>
      
        <li><a href="/react/blog/2016/11/16/react-v15.4.0.html">React v15.4.0</a></li>
      
        <li><a href="/react/blog/2016/09/28/our-first-50000-stars.html">Our First 50,000 Stars</a></li>
      
        <li><a href="/react/blog/2016/08/05/relay-state-of-the-state.html">Relay: State of the State</a></li>
      
        <li><a href="/react/blog/2016/07/22/create-apps-with-no-configuration.html">Create Apps with No Configuration</a></li>
      
        <li><a href="/react/blog/2016/07/13/mixins-considered-harmful.html">Mixins Considered Harmful</a></li>
      
        <li><a href="/react/blog/2016/07/11/introducing-reacts-error-code-system.html">Introducing React's Error Code System</a></li>
      
        <li><a href="/react/blog/2016/04/08/react-v15.0.1.html">React v15.0.1</a></li>
      
        <li><a href="/react/blog/2016/04/07/react-v15.html">React v15.0</a></li>
      
        <li><a href="/react/blog/2016/03/29/react-v0.14.8.html">React v0.14.8</a></li>
      
      <li><a href="/react/blog/all.html">All posts ...</a></li>
    </ul>
  </div>
</div>

  <div class="inner-content">
    
      <div class="post-list-item">
        

<h1>

  <a href="/react/blog/2015/12/29/react-v0.14.4.html">React v0.14.4</a>

</h1>

<p class="meta">
  December 29, 2015
  by
  
    
      <a href="http://benalpert.com">Ben Alpert</a>
    
    
  
</p>

<hr>

<div class="post">
  <p>Happy December! We have a minor point release today. It has just a few small bug fixes.</p>

<p>The release is now available for download:</p>

<ul>
<li><strong>React</strong><br>
Dev build with warnings: <a href="https://fb.me/react-0.14.4.js">https://fb.me/react-0.14.4.js</a><br>
Minified build for production: <a href="https://fb.me/react-0.14.4.min.js">https://fb.me/react-0.14.4.min.js</a><br></li>
<li><strong>React with Add-Ons</strong><br>
Dev build with warnings: <a href="https://fb.me/react-with-addons-0.14.4.js">https://fb.me/react-with-addons-0.14.4.js</a><br>
Minified build for production: <a href="https://fb.me/react-with-addons-0.14.4.min.js">https://fb.me/react-with-addons-0.14.4.min.js</a><br></li>
<li><strong>React DOM</strong> (include React in the page before React DOM)<br>
Dev build with warnings: <a href="https://fb.me/react-dom-0.14.4.js">https://fb.me/react-dom-0.14.4.js</a><br>
Minified build for production: <a href="https://fb.me/react-dom-0.14.4.min.js">https://fb.me/react-dom-0.14.4.min.js</a><br></li>
<li><strong>React DOM Server</strong> (include React in the page before React DOM Server)<br>
Dev build with warnings: <a href="https://fb.me/react-dom-server-0.14.4.js">https://fb.me/react-dom-server-0.14.4.js</a><br>
Minified build for production: <a href="https://fb.me/react-dom-server-0.14.4.min.js">https://fb.me/react-dom-server-0.14.4.min.js</a><br></li>
</ul>

<p>We&#39;ve also published version <code>0.14.4</code> of the <code>react</code>, <code>react-dom</code>, and addons packages on npm and the <code>react</code> package on bower.</p>

<hr>

<h2>Changelog</h2>

<h3>React</h3>

<ul>
<li>Minor internal changes for better compatibility with React Native</li>
</ul>

<h3>React DOM</h3>

<ul>
<li>The <code>autoCapitalize</code> and <code>autoCorrect</code> props are now set as attributes in the DOM instead of properties to improve cross-browser compatibility</li>
<li>Fixed bug with controlled <code>&lt;select&gt;</code> elements not handling updates properly</li>
</ul>

<h3>React Perf Add-on</h3>

<ul>
<li>Some DOM operation names have been updated for clarity in the output of <code>.printDOM()</code></li>
</ul>

</div>



      </div>
    
      <div class="post-list-item">
        

<h1>

  <a href="/react/blog/2015/12/18/react-components-elements-and-instances.html">React Components, Elements, and Instances</a>

</h1>

<p class="meta">
  December 18, 2015
  by
  
    
      <a href="https://twitter.com/dan_abramov">Dan Abramov</a>
    
    
  
</p>

<hr>

<div class="post">
  <p>The difference between <strong>components, their instances, and elements</strong> confuses many React beginners. Why are there three different terms to refer to something that is painted on screen?</p>

<h2>Managing the Instances</h2>

<p>If you’re new to React, you probably only worked with component classes and instances before. For example, you may declare a <code>Button</code> <em>component</em> by creating a class. When the app is running, you may have several <em>instances</em> of this component on screen, each with its own properties and local state. This is the traditional object-oriented UI programming. Why introduce <em>elements</em>?</p>

<p>In this traditional UI model, it is up to you to take care of creating and destroying child component instances. If a <code>Form</code> component wants to render a <code>Button</code> component, it needs to create its instance, and manually keep it up to date with any new information.</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kr">class</span> <span class="nx">Form</span> <span class="kr">extends</span> <span class="nx">TraditionalObjectOrientedView</span> <span class="p">{</span>
  <span class="nx">render</span><span class="p">()</span> <span class="p">{</span>
    <span class="c1">// Read some data passed to the view</span>
    <span class="kr">const</span> <span class="p">{</span> <span class="nx">isSubmitted</span><span class="p">,</span> <span class="nx">buttonText</span> <span class="p">}</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">attrs</span><span class="p">;</span>

    <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">isSubmitted</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">button</span><span class="p">)</span> <span class="p">{</span>
      <span class="c1">// Form is not yet submitted. Create the button!</span>
      <span class="k">this</span><span class="p">.</span><span class="nx">button</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Button</span><span class="p">({</span>
        <span class="nx">children</span><span class="o">:</span> <span class="nx">buttonText</span><span class="p">,</span>
        <span class="nx">color</span><span class="o">:</span> <span class="s1">&#39;blue&#39;</span>
      <span class="p">});</span>
      <span class="k">this</span><span class="p">.</span><span class="nx">el</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">button</span><span class="p">.</span><span class="nx">el</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">button</span><span class="p">)</span> <span class="p">{</span>
      <span class="c1">// The button is visible. Update its text!</span>
      <span class="k">this</span><span class="p">.</span><span class="nx">button</span><span class="p">.</span><span class="nx">attrs</span><span class="p">.</span><span class="nx">children</span> <span class="o">=</span> <span class="nx">buttonText</span><span class="p">;</span>
      <span class="k">this</span><span class="p">.</span><span class="nx">button</span><span class="p">.</span><span class="nx">render</span><span class="p">();</span>
    <span class="p">}</span>

    <span class="k">if</span> <span class="p">(</span><span class="nx">isSubmitted</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="p">.</span><span class="nx">button</span><span class="p">)</span> <span class="p">{</span>
      <span class="c1">// Form was submitted. Destroy the button!</span>
      <span class="k">this</span><span class="p">.</span><span class="nx">el</span><span class="p">.</span><span class="nx">removeChild</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">button</span><span class="p">.</span><span class="nx">el</span><span class="p">);</span>
      <span class="k">this</span><span class="p">.</span><span class="nx">button</span><span class="p">.</span><span class="nx">destroy</span><span class="p">();</span>
    <span class="p">}</span>

    <span class="k">if</span> <span class="p">(</span><span class="nx">isSubmitted</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">message</span><span class="p">)</span> <span class="p">{</span>
      <span class="c1">// Form was submitted. Show the success message!</span>
      <span class="k">this</span><span class="p">.</span><span class="nx">message</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Message</span><span class="p">({</span> <span class="nx">text</span><span class="o">:</span> <span class="s1">&#39;Success!&#39;</span> <span class="p">});</span>
      <span class="k">this</span><span class="p">.</span><span class="nx">el</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">message</span><span class="p">.</span><span class="nx">el</span><span class="p">);</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>This is pseudocode, but it is more or less what you end up with when you write composite UI code that behaves consistently in an object-oriented way using a library like Backbone.</p>

<p>Each component instance has to keep references to its DOM node and to the instances of the children components, and create, update, and destroy them when the time is right. The lines of code grow as the square of the number of possible states of the component, and the parents have direct access to their children component instances, making it hard to decouple them in the future.</p>

<p>So how is React different?</p>

<h2>Elements Describe the Tree</h2>

<p>In React, this is where the <em>elements</em> come to rescue. <strong>An element is a plain object <em>describing</em> a component instance or DOM node and its desired properties.</strong> It contains only information about the component type (for example, a <code>Button</code>), its properties (for example, its <code>color</code>), and any child elements inside it.</p>

<p>An element is not an actual instance. Rather, it is a way to tell React what you <em>want</em> to see on the screen. You can’t call any methods on the element. It’s just an immutable description object with two fields: <code>type: (string | ReactClass)</code> and <code>props: Object</code><sup id="fnref1"><a href="#fn1" rel="footnote">1</a></sup>.</p>

<h3>DOM Elements</h3>

<p>When an element’s <code>type</code> is a string, it represents a DOM node with that tag name, and <code>props</code> correspond to its attributes. This is what React will render. For example:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="p">{</span>
  <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;button&#39;</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">className</span><span class="o">:</span> <span class="s1">&#39;button button-blue&#39;</span><span class="p">,</span>
    <span class="nx">children</span><span class="o">:</span> <span class="p">{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">children</span><span class="o">:</span> <span class="s1">&#39;OK!&#39;</span>
      <span class="p">}</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>This element is just a way to represent the following HTML as a plain object:</p>
<div class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt">&lt;button</span> <span class="na">class=</span><span class="s">&#39;button button-blue&#39;</span><span class="nt">&gt;</span>
  <span class="nt">&lt;b&gt;</span>
    OK!
  <span class="nt">&lt;/b&gt;</span>
<span class="nt">&lt;/button&gt;</span>
</code></pre></div>
<p>Note how elements can be nested. By convention, when we want to create an element tree, we specify one or more child elements as the <code>children</code> prop of their containing element.</p>

<p>What’s important is that both child and parent elements are <em>just descriptions and not the actual instances</em>. They don’t refer to anything on the screen when you create them. You can create them and throw them away, and it won’t matter much.</p>

<p>React elements are easy to traverse, don’t need to be parsed, and of course they are much lighter than the actual DOM elements—they’re just objects!</p>

<h3>Component Elements</h3>

<p>However, the <code>type</code> of an element can also be a function or a class corresponding to a React component:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="p">{</span>
  <span class="nx">type</span><span class="o">:</span> <span class="nx">Button</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">color</span><span class="o">:</span> <span class="s1">&#39;blue&#39;</span><span class="p">,</span>
    <span class="nx">children</span><span class="o">:</span> <span class="s1">&#39;OK!&#39;</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>This is the core idea of React.</p>

<p><strong>An element describing a component is also an element, just like an element describing the DOM node. They can be nested and mixed with each other.</strong></p>

<p>This feature lets you define a <code>DangerButton</code> component as a <code>Button</code> with a specific <code>color</code> property value without worrying about whether <code>Button</code> renders to a DOM <code>&lt;button&gt;</code>, a <code>&lt;div&gt;</code>, or something else entirely:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kr">const</span> <span class="nx">DangerButton</span> <span class="o">=</span> <span class="p">({</span> <span class="nx">children</span> <span class="p">})</span> <span class="o">=&gt;</span> <span class="p">({</span>
  <span class="nx">type</span><span class="o">:</span> <span class="nx">Button</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">color</span><span class="o">:</span> <span class="s1">&#39;red&#39;</span><span class="p">,</span>
    <span class="nx">children</span><span class="o">:</span> <span class="nx">children</span>
  <span class="p">}</span>
<span class="p">});</span>
</code></pre></div>
<p>You can mix and match DOM and component elements in a single element tree:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kr">const</span> <span class="nx">DeleteAccount</span> <span class="o">=</span> <span class="p">()</span> <span class="o">=&gt;</span> <span class="p">({</span>
  <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;div&#39;</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">children</span><span class="o">:</span> <span class="p">[{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;p&#39;</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">children</span><span class="o">:</span> <span class="s1">&#39;Are you sure?&#39;</span>
      <span class="p">}</span>
    <span class="p">},</span> <span class="p">{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="nx">DangerButton</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">children</span><span class="o">:</span> <span class="s1">&#39;Yep&#39;</span>
      <span class="p">}</span>
    <span class="p">},</span> <span class="p">{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="nx">Button</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">color</span><span class="o">:</span> <span class="s1">&#39;blue&#39;</span><span class="p">,</span>
        <span class="nx">children</span><span class="o">:</span> <span class="s1">&#39;Cancel&#39;</span>
      <span class="p">}</span>
   <span class="p">}]</span>
<span class="p">});</span>
</code></pre></div>
<p>Or, if you prefer JSX:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kr">const</span> <span class="nx">DeleteAccount</span> <span class="o">=</span> <span class="p">()</span> <span class="o">=&gt;</span> <span class="p">(</span>
  <span class="o">&lt;</span><span class="nx">div</span><span class="o">&gt;</span>
    <span class="o">&lt;</span><span class="nx">p</span><span class="o">&gt;</span><span class="nx">Are</span> <span class="nx">you</span> <span class="nx">sure</span><span class="o">?&lt;</span><span class="err">/p&gt;</span>
    <span class="o">&lt;</span><span class="nx">DangerButton</span><span class="o">&gt;</span><span class="nx">Yep</span><span class="o">&lt;</span><span class="err">/DangerButton&gt;</span>
    <span class="o">&lt;</span><span class="nx">Button</span> <span class="nx">color</span><span class="o">=</span><span class="s1">&#39;blue&#39;</span><span class="o">&gt;</span><span class="nx">Cancel</span><span class="o">&lt;</span><span class="err">/Button&gt;</span>
  <span class="o">&lt;</span><span class="err">/div&gt;</span>
<span class="p">);</span>
</code></pre></div>
<p>This mix and matching helps keep components decoupled from each other, as they can express both <em>is-a</em> and <em>has-a</em> relationships exclusively through composition:</p>

<ul>
<li><code>Button</code> is a DOM <code>&lt;button&gt;</code> with specific properties.</li>
<li><code>DangerButton</code> is a <code>Button</code> with specific properties.</li>
<li><code>DeleteAccount</code> contains a <code>Button</code> and a <code>DangerButton</code> inside a <code>&lt;div&gt;</code>.</li>
</ul>

<h3>Components Encapsulate Element Trees</h3>

<p>When React sees an element with a function or class <code>type</code>, it knows to ask <em>that</em> component what element it renders to, given the corresponding <code>props</code>.</p>

<p>When it sees this element:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="p">{</span>
  <span class="nx">type</span><span class="o">:</span> <span class="nx">Button</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">color</span><span class="o">:</span> <span class="s1">&#39;blue&#39;</span><span class="p">,</span>
    <span class="nx">children</span><span class="o">:</span> <span class="s1">&#39;OK!&#39;</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>React will ask <code>Button</code> what it renders to. The <code>Button</code> will return this element:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="p">{</span>
  <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;button&#39;</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">className</span><span class="o">:</span> <span class="s1">&#39;button button-blue&#39;</span><span class="p">,</span>
    <span class="nx">children</span><span class="o">:</span> <span class="p">{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">children</span><span class="o">:</span> <span class="s1">&#39;OK!&#39;</span>
      <span class="p">}</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>React will repeat this process until it knows the underlying DOM tag elements for every component on the page.</p>

<p>React is like a child asking “what is Y” for every “X is Y” you explain to them until they figure out every little thing in the world.</p>

<p>Remember the <code>Form</code> example above? It can be written in React as follows<sup id="fnref1"><a href="#fn1" rel="footnote">1</a></sup>:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kr">const</span> <span class="nx">Form</span> <span class="o">=</span> <span class="p">({</span> <span class="nx">isSubmitted</span><span class="p">,</span> <span class="nx">buttonText</span> <span class="p">})</span> <span class="o">=&gt;</span> <span class="p">{</span>
  <span class="k">if</span> <span class="p">(</span><span class="nx">isSubmitted</span><span class="p">)</span> <span class="p">{</span>
    <span class="c1">// Form submitted! Return a message element.</span>
    <span class="k">return</span> <span class="p">{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="nx">Message</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">text</span><span class="o">:</span> <span class="s1">&#39;Success!&#39;</span>
      <span class="p">}</span>
    <span class="p">};</span>
  <span class="p">}</span>

  <span class="c1">// Form is still visible! Return a button element.</span>
  <span class="k">return</span> <span class="p">{</span>
    <span class="nx">type</span><span class="o">:</span> <span class="nx">Button</span><span class="p">,</span>
    <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
      <span class="nx">children</span><span class="o">:</span> <span class="nx">buttonText</span><span class="p">,</span>
      <span class="nx">color</span><span class="o">:</span> <span class="s1">&#39;blue&#39;</span>
    <span class="p">}</span>
  <span class="p">};</span>
<span class="p">};</span>
</code></pre></div>
<p>That’s it! For a React component, props are the input, and an element tree is the output.</p>

<p><strong>The returned element tree can contain both elements describing DOM nodes, and elements describing other components. This lets you compose independent parts of UI without relying on their internal DOM structure.</strong></p>

<p>We let React create, update, and destroy instances. We <em>describe</em> them with elements we return from the components, and React takes care of managing the instances.</p>

<h3>Components Can Be Classes or Functions</h3>

<p>In the code above, <code>Form</code>, <code>Message</code>, and <code>Button</code> are React components. They can either be written as functions, like above, or as classes descending from <code>React.Component</code>. These three ways to declare a component are mostly equivalent:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="c1">// 1) As a function of props</span>
<span class="kr">const</span> <span class="nx">Button</span> <span class="o">=</span> <span class="p">({</span> <span class="nx">children</span><span class="p">,</span> <span class="nx">color</span> <span class="p">})</span> <span class="o">=&gt;</span> <span class="p">({</span>
  <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;button&#39;</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">className</span><span class="o">:</span> <span class="s1">&#39;button button-&#39;</span> <span class="o">+</span> <span class="nx">color</span><span class="p">,</span>
    <span class="nx">children</span><span class="o">:</span> <span class="p">{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">children</span><span class="o">:</span> <span class="nx">children</span>
      <span class="p">}</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">});</span>

<span class="c1">// 2) Using the React.createClass() factory</span>
<span class="kr">const</span> <span class="nx">Button</span> <span class="o">=</span> <span class="nx">React</span><span class="p">.</span><span class="nx">createClass</span><span class="p">({</span>
  <span class="nx">render</span><span class="p">()</span> <span class="p">{</span>
    <span class="kr">const</span> <span class="p">{</span> <span class="nx">children</span><span class="p">,</span> <span class="nx">color</span> <span class="p">}</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">props</span><span class="p">;</span>
    <span class="k">return</span> <span class="p">{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;button&#39;</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">className</span><span class="o">:</span> <span class="s1">&#39;button button-&#39;</span> <span class="o">+</span> <span class="nx">color</span><span class="p">,</span>
        <span class="nx">children</span><span class="o">:</span> <span class="p">{</span>
          <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span>
          <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
            <span class="nx">children</span><span class="o">:</span> <span class="nx">children</span>
          <span class="p">}</span>
        <span class="p">}</span>
      <span class="p">}</span>
    <span class="p">};</span>
  <span class="p">}</span>
<span class="p">});</span>

<span class="c1">// 3) As an ES6 class descending from React.Component</span>
<span class="kr">class</span> <span class="nx">Button</span> <span class="kr">extends</span> <span class="nx">React</span><span class="p">.</span><span class="nx">Component</span> <span class="p">{</span>
  <span class="nx">render</span><span class="p">()</span> <span class="p">{</span>
    <span class="kr">const</span> <span class="p">{</span> <span class="nx">children</span><span class="p">,</span> <span class="nx">color</span> <span class="p">}</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">props</span><span class="p">;</span>
    <span class="k">return</span> <span class="p">{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;button&#39;</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">className</span><span class="o">:</span> <span class="s1">&#39;button button-&#39;</span> <span class="o">+</span> <span class="nx">color</span><span class="p">,</span>
        <span class="nx">children</span><span class="o">:</span> <span class="p">{</span>
          <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span>
          <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
            <span class="nx">children</span><span class="o">:</span> <span class="nx">children</span>
          <span class="p">}</span>
        <span class="p">}</span>
      <span class="p">}</span>
    <span class="p">};</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>When a component is defined as a class, it is a little bit more powerful than a functional component. It can store some local state and perform custom logic when the corresponding DOM node is created or destroyed.</p>

<p>A functional component is less powerful but is simpler, and acts like a class component with just a single <code>render()</code> method. Unless you need features available only in a class, we encourage you to use functional components instead.</p>

<p><strong>However, whether functions or classes, fundamentally they are all components to React. They take the props as their input, and return the elements as their output.</strong></p>

<h3>Top-Down Reconciliation</h3>

<p>When you call:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="nx">ReactDOM</span><span class="p">.</span><span class="nx">render</span><span class="p">({</span>
  <span class="nx">type</span><span class="o">:</span> <span class="nx">Form</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">isSubmitted</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
    <span class="nx">buttonText</span><span class="o">:</span> <span class="s1">&#39;OK!&#39;</span>
  <span class="p">}</span>
<span class="p">},</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;root&#39;</span><span class="p">));</span>
</code></pre></div>
<p>React will ask the <code>Form</code> component what element tree it returns, given those <code>props</code>. It will gradually “refine” its understanding of your component tree in terms of simpler primitives:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="c1">// React: You told me this...</span>
<span class="p">{</span>
  <span class="nx">type</span><span class="o">:</span> <span class="nx">Form</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">isSubmitted</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
    <span class="nx">buttonText</span><span class="o">:</span> <span class="s1">&#39;OK!&#39;</span>
  <span class="p">}</span>
<span class="p">}</span>

<span class="c1">// React: ...And Form told me this...</span>
<span class="p">{</span>
  <span class="nx">type</span><span class="o">:</span> <span class="nx">Button</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">children</span><span class="o">:</span> <span class="s1">&#39;OK!&#39;</span><span class="p">,</span>
    <span class="nx">color</span><span class="o">:</span> <span class="s1">&#39;blue&#39;</span>
  <span class="p">}</span>
<span class="p">}</span>

<span class="c1">// React: ...and Button told me this! I guess I&#39;m done.</span>
<span class="p">{</span>
  <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;button&#39;</span><span class="p">,</span>
  <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
    <span class="nx">className</span><span class="o">:</span> <span class="s1">&#39;button button-blue&#39;</span><span class="p">,</span>
    <span class="nx">children</span><span class="o">:</span> <span class="p">{</span>
      <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span>
      <span class="nx">props</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">children</span><span class="o">:</span> <span class="s1">&#39;OK!&#39;</span>
      <span class="p">}</span>
    <span class="p">}</span>
  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>This is a part of the process that React calls <a href="/react/docs/reconciliation.html">reconciliation</a> which starts when you call <a href="/react/docs/top-level-api.html#reactdom.render"><code>ReactDOM.render()</code></a> or <a href="/react/docs/component-api.html#setstate"><code>setState()</code></a>. By the end of the reconciliation, React knows the result DOM tree, and a renderer like <code>react-dom</code> or <code>react-native</code> applies the minimal set of changes necessary to update the DOM nodes (or the platform-specific views in case of React Native).</p>

<p>This gradual refining process is also the reason React apps are easy to optimize. If some parts of your component tree become too large for React to visit efficiently, you can tell it to <a href="/react/docs/advanced-performance.html">skip this “refining” and diffing certain parts of the tree if the relevant props have not changed</a>. It is very fast to calculate whether the props have changed if they are immutable, so React and immutability work great together, and can provide great optimizations with the minimal effort.</p>

<p>You might have noticed that this blog entry talks a lot about components and elements, and not so much about the instances. The truth is, instances have much less importance in React than in most object-oriented UI frameworks.</p>

<p>Only components declared as classes have instances, and you never create them directly: React does that for you. While <a href="/react/docs/more-about-refs.html">mechanisms for a parent component instance to access a child component instance</a> exist, they are only used for imperative actions (such as setting focus on a field), and should generally be avoided.</p>

<p>React takes care of creating an instance for every class component, so you can write components in an object-oriented way with methods and local state, but other than that, instances are not very important in the React’s programming model and are managed by React itself.</p>

<h2>Summary</h2>

<p>An <em>element</em> is a plain object describing what you want to appear on the screen in terms of the DOM nodes or other components. Elements can contain other elements in their props. Creating a React element is cheap. Once an element is created, it is never mutated.</p>

<p>A <em>component</em> can be declared in several different ways. It can be a class with a <code>render()</code> method. Alternatively, in simple cases, it can be defined as a function. In either case, it takes props as an input, and returns an element tree as the output.</p>

<p>When a component receives some props as an input, it is because a particular parent component returned an element with its <code>type</code> and these props. This is why people say that the props flows one way in React: from parents to children.</p>

<p>An <em>instance</em> is what you refer to as <code>this</code> in the component class you write. It is useful for <a href="/react/docs/component-api.html">storing local state and reacting to the lifecycle events</a>.</p>

<p>Functional components don’t have instances at all. Class components have instances, but you never need to create a component instance directly—React takes care of this.</p>

<p>Finally, to create elements, use <a href="/react/docs/top-level-api.html#react.createelement"><code>React.createElement()</code></a>, <a href="/react/docs/jsx-in-depth.html">JSX</a>, or an <a href="/react/docs/top-level-api.html#react.createfactory">element factory helper</a>. Don’t write elements as plain objects in the real code—just know that they are plain objects under the hood.</p>

<h2>Further Reading</h2>

<ul>
<li><a href="/react/blog/2014/10/14/introducing-react-elements.html">Introducing React Elements</a></li>
<li><a href="/react/blog/2015/02/24/streamlining-react-elements.html">Streamlining React Elements</a></li>
<li><a href="/react/docs/glossary.html">React (Virtual) DOM Terminology</a></li>
</ul>

<div class="footnotes">
<hr>
<ol>

<li id="fn1">
<p>All React elements require an additional <code>$$typeof: Symbol.for(&#39;react.element&#39;)</code> field declared on the object for <a href="https://github.com/facebook/react/pull/4832">security reasons</a>. It is omitted in the examples above. This blog entry uses inline objects for elements to give you an idea of what’s happening underneath but the code won’t run as is unless you either add <code>$$typeof</code> to the elements, or change the code to use <code>React.createElement()</code> or JSX.&nbsp;<a href="#fnref1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>

</div>



      </div>
    
      <div class="post-list-item">
        

<h1>

  <a href="/react/blog/2015/12/16/ismounted-antipattern.html">isMounted is an Antipattern</a>

</h1>

<p class="meta">
  December 16, 2015
  by
  
    
      <a href="http://www.jimsproch.com">Jim Sproch</a>
    
    
  
</p>

<hr>

<div class="post">
  <p>As we move closer to officially deprecating isMounted, it&#39;s worth understanding why the function is an antipattern, and how to write code without the isMounted function.</p>

<p>The primary use case for <code>isMounted()</code> is to avoid calling <code>setState()</code> after a component has unmounted, because calling <code>setState()</code> after a component has unmounted will emit a warning. The “setState warning” exists to help you catch bugs, because calling <code>setState()</code> on an unmounted component is an indication that your app/component has somehow failed to clean up properly. Specifically, calling <code>setState()</code> in an unmounted component means that your app is still holding a reference to the component after the component has been unmounted - which often indicates a memory leak!</p>

<p>To avoid the error message, people often add lines like this:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="k">if</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isMounted</span><span class="p">())</span> <span class="p">{</span> <span class="c1">// This is bad.</span>
  <span class="k">this</span><span class="p">.</span><span class="nx">setState</span><span class="p">({...});</span>
<span class="p">}</span>
</code></pre></div>
<p>Checking <code>isMounted</code> before calling <code>setState()</code> does eliminate the warning, but it also defeats the purpose of the warning, since now you will never get the warning (even when you should!)</p>

<p>Other uses of <code>isMounted()</code> are similarly erroneous; using <code>isMounted()</code> is a code smell because the only reason you would check is because you think you might be holding a reference after the component has unmounted.</p>

<p>An easy migration strategy for anyone upgrading their code to avoid <code>isMounted()</code> is to track the mounted status yourself.  Just set a <code>_isMounted</code> property to true in <code>componentDidMount</code> and set it to false in <code>componentWillUnmount</code>, and use this variable to check your component&#39;s status.</p>

<p>An optimal solution would be to find places where <code>setState()</code> might be called after a component has unmounted, and fix them. Such situations most commonly occur due to callbacks, when a component is waiting for some data and gets unmounted before the data arrives. Ideally, any callbacks should be canceled in <code>componentWillUnmount</code>, prior to unmounting.</p>

<p>For instance, if you are using a Flux store in your component, you must unsubscribe in <code>componentWillUnmount</code>:</p>
<div class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="kr">class</span> <span class="nx">MyComponent</span> <span class="kr">extends</span> <span class="nx">React</span><span class="p">.</span><span class="nx">Component</span> <span class="p">{</span>
  <span class="nx">componentDidMount</span><span class="p">()</span> <span class="p">{</span>
    <span class="nx">mydatastore</span><span class="p">.</span><span class="nx">subscribe</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
  <span class="p">}</span>
  <span class="nx">render</span><span class="p">()</span> <span class="p">{</span>
    <span class="p">...</span>
  <span class="p">}</span>
  <span class="nx">componentWillUnmount</span><span class="p">()</span> <span class="p">{</span>
<span class="hll">    <span class="nx">mydatastore</span><span class="p">.</span><span class="nx">unsubscribe</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
</span>  <span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>If you use ES6 promises, you may need to wrap your promise in order to make it cancelable.</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kr">const</span> <span class="nx">cancelablePromise</span> <span class="o">=</span> <span class="nx">makeCancelable</span><span class="p">(</span>
  <span class="k">new</span> <span class="nx">Promise</span><span class="p">(</span><span class="nx">r</span> <span class="o">=&gt;</span> <span class="nx">component</span><span class="p">.</span><span class="nx">setState</span><span class="p">({...}}))</span>
<span class="p">);</span>

<span class="nx">cancelablePromise</span>
  <span class="p">.</span><span class="nx">promise</span>
  <span class="p">.</span><span class="nx">then</span><span class="p">(()</span> <span class="o">=&gt;</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;resolved&#39;</span><span class="p">))</span>
  <span class="p">.</span><span class="k">catch</span><span class="p">((</span><span class="nx">reason</span><span class="p">)</span> <span class="o">=&gt;</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;isCanceled&#39;</span><span class="p">,</span> <span class="nx">reason</span><span class="p">.</span><span class="nx">isCanceled</span><span class="p">));</span>

<span class="nx">cancelablePromise</span><span class="p">.</span><span class="nx">cancel</span><span class="p">();</span> <span class="c1">// Cancel the promise</span>
</code></pre></div>
<p>Where <code>makeCancelable</code> is <a href="https://github.com/facebook/react/issues/5465#issuecomment-157888325">defined by @istarkov</a> as:</p>
<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kr">const</span> <span class="nx">makeCancelable</span> <span class="o">=</span> <span class="p">(</span><span class="nx">promise</span><span class="p">)</span> <span class="o">=&gt;</span> <span class="p">{</span>
  <span class="kd">let</span> <span class="nx">hasCanceled_</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>

  <span class="kr">const</span> <span class="nx">wrappedPromise</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Promise</span><span class="p">((</span><span class="nx">resolve</span><span class="p">,</span> <span class="nx">reject</span><span class="p">)</span> <span class="o">=&gt;</span> <span class="p">{</span>
    <span class="nx">promise</span><span class="p">.</span><span class="nx">then</span><span class="p">((</span><span class="nx">val</span><span class="p">)</span> <span class="o">=&gt;</span>
      <span class="nx">hasCanceled_</span> <span class="o">?</span> <span class="nx">reject</span><span class="p">({</span><span class="nx">isCanceled</span><span class="o">:</span> <span class="kc">true</span><span class="p">})</span> <span class="o">:</span> <span class="nx">resolve</span><span class="p">(</span><span class="nx">val</span><span class="p">)</span>
    <span class="p">);</span>
    <span class="nx">promise</span><span class="p">.</span><span class="k">catch</span><span class="p">((</span><span class="nx">error</span><span class="p">)</span> <span class="o">=&gt;</span>
      <span class="nx">hasCanceled_</span> <span class="o">?</span> <span class="nx">reject</span><span class="p">({</span><span class="nx">isCanceled</span><span class="o">:</span> <span class="kc">true</span><span class="p">})</span> <span class="o">:</span> <span class="nx">reject</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span>
    <span class="p">);</span>
  <span class="p">});</span>

  <span class="k">return</span> <span class="p">{</span>
    <span class="nx">promise</span><span class="o">:</span> <span class="nx">wrappedPromise</span><span class="p">,</span>
    <span class="nx">cancel</span><span class="p">()</span> <span class="p">{</span>
      <span class="nx">hasCanceled_</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
    <span class="p">},</span>
  <span class="p">};</span>
<span class="p">};</span>
</code></pre></div>
<p>As an added bonus for getting your code cleaned up early, getting rid of <code>isMounted()</code> makes it one step easier for you to upgrade to ES6 classes, where using <code>isMounted()</code> is already prohibited.  Happy coding!</p>

</div>



      </div>
    
      <div class="post-list-item">
        

<h1>

  <a href="/react/blog/2015/12/04/react-js-conf-2016-diversity-scholarship.html">React.js Conf 2016 Diversity Scholarship</a>

</h1>

<p class="meta">
  December  4, 2015
  by
  
    
      <a href="https://twitter.com/zpao">Paul O’Shannessy</a>
    
    
  
</p>

<hr>

<div class="post">
  <p>I am thrilled to announced that we will be organizing another diversity scholarship program for the upcoming React.js Conf! The tech industry is suffering from a lack of diversity, but it&#39;s important to us that we have a thriving community that is made up of people with a variety of experiences and viewpoints.</p>

<p>When we ran this program last year, we had <em>over 200</em> people apply for only 10 tickets. There were so many people that we wanted to bring in but we couldn&#39;t. The results were still awesome, and we had bright individuals from around the world attending who would have otherwise been unable to. These attendees took part in discussions at the conference and brought perspectives that we might not have otherwise seen there.</p>

<p>This year we&#39;re excited to bring back the scholarship, but we&#39;ve set aside <strong>40 tickets</strong> because we really believe that it&#39;s important to do our best to make sure we have an even more diverse audience.</p>

<p>This is something I&#39;m personally really excited to be a part of. I know the rest of the team is as well. We&#39;re really proud to have everyone at Facebook providing support and funding for this.</p>

<p>The details of the scholarship are provided below (or you can <a href="http://goo.gl/forms/PEmKj8oUp4">go directly to the application</a>). I encourage you to apply! If you don&#39;t feel like you are eligible yourself, you can still help – send this along to friends, family, coworkers, acquaintances, or anybody who might be interested. And even if you haven&#39;t spoken before, please consider <a href="http://conf.reactjs.com/">submitting a proposal for a talk</a> (either 30 minutes or just 5 minutes) - we&#39;re hoping to have a very diverse group of speakers in addition to attendees.</p>

<hr>

<p>Facebook is excited to announce that we are now accepting applications for the React.js Conf Diversity Scholarship!</p>

<p>Beginning today, those studying or working in computer science or a related field can apply for a partial scholarship to attend the React.js Conf in San Francisco, CA on February 22 &amp; 23, 2016.</p>

<p>React opens a world of new possibilities such as server-side rendering, real-time updates, different rendering targets like SVG and canvas. React Native makes is easy to use the same concepts and technologies to build native mobile experiences on iOS and Android. Join us at React.js Conf to shape the future of client-side applications! For more information about the React.js conference, please see <a href="http://conf.reactjs.com/">the website</a>.</p>

<p>At Facebook, we believe that anyone anywhere can make a positive impact by developing products to make the world more open and connected to the people and things they care about. Given the current realities of the tech industry and the lack of representation of communities we seek to serve, applicants currently under-represented in Computer Science and related fields are strongly encouraged to apply. Facebook will make determinations on scholarship recipients in its sole discretion. Facebook complies with all equal opportunity laws.</p>

<p>To apply for the scholarship, please visit the application page: <strong><a href="http://goo.gl/forms/PEmKj8oUp4">http://goo.gl/forms/PEmKj8oUp4</a></strong></p>

<h2>Award Includes</h2>

<ul>
<li>Paid registration fee for the React.js Conf Feburary 22 &amp; 23 in downtown San Francisco, CA</li>
<li>Paid lodging expenses for February 21, 22, 23</li>
</ul>

<h2>Important Dates</h2>

<ul>
<li>Sunday December 13th 2015 - 11:59 PST: Applications for the React.js Conf Scholarship must be submitted in full</li>
<li>Wednesday, December 16th, 2015: Award recipients will be notified by email of their acceptance</li>
<li>Monday &amp; Tuesday, February 22 &amp; 23, 2016: React.js Conf</li>
</ul>

<h2>Eligibility</h2>

<ul>
<li>Must currently be studying or working in Computer Science or a related field</li>
<li>International applicants are welcome, but you will be responsible for securing your own visa to attend the conference</li>
<li>You must be able to provide your own transportation to San Francisco</li>
<li>You must be available to attend the full duration of React.js Conf on February 22 &amp; 23 in San Francisco, CA</li>
</ul>

</div>



      </div>
    
      <div class="post-list-item">
        

<h1>

  <a href="/react/blog/2015/11/18/react-v0.14.3.html">React v0.14.3</a>

</h1>

<p class="meta">
  November 18, 2015
  by
  
    
      <a href="https://twitter.com/zpao">Paul O’Shannessy</a>
    
    
  
</p>

<hr>

<div class="post">
  <p>It&#39;s time for another installment of React patch releases! We didn&#39;t break anything in v0.14.2 but we do have a couple of other bugs we&#39;re fixing. The biggest change in this release is actually an addition of a new built file. We heard from a number of people that they still need the ability to use React to render to a string on the client. While the use cases are not common and there are other ways to achieve this, we decided that it&#39;s still valuable to support. So we&#39;re now building <code>react-dom-server.js</code>, which will be shipped to Bower and in the <code>dist/</code> directory of the <code>react-dom</code> package on npm. This file works the same way as <code>react-dom.js</code> and therefore requires that the primary React build has already been included on the page.</p>

<p>The release is now available for download:</p>

<ul>
<li><strong>React</strong><br>
Dev build with warnings: <a href="https://fb.me/react-0.14.3.js">https://fb.me/react-0.14.3.js</a><br>
Minified build for production: <a href="https://fb.me/react-0.14.3.min.js">https://fb.me/react-0.14.3.min.js</a><br></li>
<li><strong>React with Add-Ons</strong><br>
Dev build with warnings: <a href="https://fb.me/react-with-addons-0.14.3.js">https://fb.me/react-with-addons-0.14.3.js</a><br>
Minified build for production: <a href="https://fb.me/react-with-addons-0.14.3.min.js">https://fb.me/react-with-addons-0.14.3.min.js</a><br></li>
<li><strong>React DOM</strong> (include React in the page before React DOM)<br>
Dev build with warnings: <a href="https://fb.me/react-dom-0.14.3.js">https://fb.me/react-dom-0.14.3.js</a><br>
Minified build for production: <a href="https://fb.me/react-dom-0.14.3.min.js">https://fb.me/react-dom-0.14.3.min.js</a><br></li>
<li><strong>React DOM Server</strong> (include React in the page before React DOM Server)<br>
Dev build with warnings: <a href="https://fb.me/react-dom-server-0.14.3.js">https://fb.me/react-dom-server-0.14.3.js</a><br>
Minified build for production: <a href="https://fb.me/react-dom-server-0.14.3.min.js">https://fb.me/react-dom-server-0.14.3.min.js</a><br></li>
</ul>

<p>We&#39;ve also published version <code>0.14.3</code> of the <code>react</code>, <code>react-dom</code>, and addons packages on npm and the <code>react</code> package on bower.</p>

<hr>

<h2>Changelog</h2>

<h3>React DOM</h3>

<ul>
<li>Added support for <code>nonce</code> attribute for <code>&lt;script&gt;</code> and <code>&lt;style&gt;</code> elements</li>
<li>Added support for <code>reversed</code> attribute for <code>&lt;ol&gt;</code> elements</li>
</ul>

<h3>React TestUtils Add-on</h3>

<ul>
<li>Fixed bug with shallow rendering and function refs</li>
</ul>

<h3>React CSSTransitionGroup Add-on</h3>

<ul>
<li>Fixed bug resulting in timeouts firing incorrectly when mounting and unmounting rapidly</li>
</ul>

<h3>React on Bower</h3>

<ul>
<li>Added <code>react-dom-server.js</code> to expose <code>renderToString</code> and <code>renderToStaticMarkup</code> for usage in the browser</li>
</ul>

</div>



      </div>
    

    <div class="pagination">
      
        <a href="/react/blog/page3/" class="previous">
          &laquo; Previous Page
        </a>
      
      
        <a href="/react/blog/page5/" class="next">
          Next Page &raquo;
        </a>
      
    </div>
  </div>
</section>


    <footer class="nav-footer">
  <section class="sitemap">
    <a href="/react/" class="nav-home">
    </a>
    <div>
      <h5><a href="/react/docs/">Docs</a></h5>
      <a href="/react/docs/hello-world.html">Quick Start</a>
      <a href="/react/docs/thinking-in-react.html">Thinking in React</a>
      <a href="/react/tutorial/tutorial.html">Tutorial</a>
      <a href="/react/docs/jsx-in-depth.html">Advanced Guides</a>
    </div>
    <div>
      <h5><a href="/react/community/support.html">Community</a></h5>
      <a href="http://stackoverflow.com/questions/tagged/reactjs" target="_blank">Stack Overflow</a>
      <a href="https://discuss.reactjs.org/" target="_blank">Discussion Forum</a>
      <a href="https://discord.gg/0ZcbPKXt5bZjGY5n" target="_blank">Reactiflux Chat</a>
      <a href="https://www.facebook.com/react" target="_blank">Facebook</a>
      <a href="https://twitter.com/reactjs" target="_blank">Twitter</a>
    </div>
    <div>
      <h5><a href="/react/community/support.html">Resources</a></h5>
      <a href="/react/community/conferences.html">Conferences</a>
      <a href="/react/community/videos.html">Videos</a>
      <a href="https://github.com/facebook/react/wiki/Examples" target="_blank">Examples</a>
      <a href="https://github.com/facebook/react/wiki/Complementary-Tools" target="_blank">Complementary Tools</a>
    </div>
    <div>
      <h5>More</h5>
      <a href="/react/blog/">Blog</a>
      <a href="https://github.com/facebook/react" target="_blank">GitHub</a>
      <a href="http://facebook.github.io/react-native/" target="_blank">React Native</a>
      <a href="/react/acknowledgements.html">Acknowledgements</a>
    </div>
  </section>
  <a href="https://code.facebook.com/projects/" target="_blank" class="fbOpenSource">
    <img src="/react/img/oss_logo.png" alt="Facebook Open Source" width="170" height="45"/>
  </a>
  <section class="copyright">
    Copyright © 2017 Facebook Inc.
  </section>
</footer>

  </div>

  <div id="fb-root"></div>
  <script src="/react/js/anchor-links.js"></script>
  <script>
    

    

    
    docsearch({
      apiKey: '36221914cce388c46d0420343e0bb32e',
      indexName: 'react',
      inputSelector: '#algolia-doc-search'
    });
  </script>
</body>
</html>
